/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package core.threads;

import core.threads.server.Server_Public_Data;
import core.threads.server.Server_Public_Thread;
import core.threads.server.communication.T_Server_Receiver;
import core.threads.server.communication.T_Server_Sender;
import core.threads.server.creation.T_Server_CaraNb_Config;
import core.threads.server.creation.T_Server_New_Game;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Invince
 */
public class T_Create_All  extends Thread{
/*----------Attributs-------------------*/
    protected boolean stop;
    protected boolean suspend;

    protected final Object semaphore;

    protected int listenPort;
/*----------Public functions------------*/
    @Override
    public void run() {
        try {
            /**-----Init-----**/
            Server_Public_Thread.tServerCaraNbConfig = new T_Server_CaraNb_Config();
            Server_Public_Thread.tServerNewGame = new T_Server_New_Game();
            Server_Public_Thread.tServerSender = new T_Server_Sender();
            Server_Public_Thread.tServerReceiver = new T_Server_Receiver(this.listenPort);
            /**----End-----**/
        } catch (UnknownHostException ex) {
            Logger.getLogger(T_Create_All.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(T_Create_All.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void stopT(){
        synchronized(this.semaphore){
            this.stop=true;
        }
    }

    public void suspendT(){
        synchronized(this.semaphore){
            this.suspend=true;
        }
    }

    public void resumeT(){
        synchronized(this.semaphore){
            this.suspend=false;
        }
    }
/*----------Private functions-----------*/
/*----------Constructor-----------------*/
    public T_Create_All(int listenPort) {
        this.semaphore=new Object();
        this.stop=false;
        this.suspend=false;
        this.listenPort=listenPort;
    }
/*----------Gets and sets---------------*/
    public Object getSemaphore() {
        return semaphore;
    }

}
